#pragma once

#ifndef ADOQuery_H
#define ADOQuery_H

#include "ADOConnection.h"

class CADOQuery
{
private:
	CString m_SQL;
	CADOConnection* m_pConn;
	_RecordsetPtr m_DataSet;
	BOOL m_Active;
public:
	void SetSQL(CString ASQL);
	CString GetSQL(void);

	void SetConnection(CADOConnection* AConn);
	CADOConnection* GetConn(void); 

	void Open(void);
	void Close(void);

	void Next(void);
	void Prev(void);
	void First(void);
	void Last(void);
	BOOL Eof(void);
	BOOL Bof(void);

	int FieldsCount(void);
	FieldsPtr GetFields(void); 

	_variant_t FieldValueByIndex(int Index);
	_variant_t FieldValueByName(CString AName);

	int FieldValueAsInt(CString AName);
	int FieldValueAsInt(int Index);
	CString FieldValueAsString(CString AName);
	CString FieldValueAsString(int Index);

	void Append();
	void Post();
	void Delete();
	void SetFieldValueByName(CString AFieldName, _variant_t Value);

	BOOL ExecSQL(void);
public:
	CADOQuery(void);
	~CADOQuery(void);
};

#endif
